package com.xiaoqi.store.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @Author Rookie Coder
 * @Description aop测试业务运行时间
 * @Date
 **/
@Aspect
@Component
@Slf4j
public class TimerAspect {

    /*
    * @Author xiaoqi
    * @Description  配置环绕方法
    * @return
    **/
    @Around("execution(* com.xiaoqi.store.service.impl.*.*(..))")
    public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {

        long startResult = System.currentTimeMillis();

        Object proceed = proceedingJoinPoint.proceed();

        long endResult = System.currentTimeMillis();

        log.info("总耗时 "+(endResult-startResult)+"ms");

        return proceed;
    }

}
